package org.sword.wechat4j.driver.message;

import org.sword.wechat4j.driver.MessageDriverI;
import org.sword.wechat4j.request.BaseMessage;
import org.sword.wechat4j.request.LinkMessage;
import org.sword.wechat4j.response.WechatResponse;
import org.sword.wechat4j.type.MsgType;

/**
 * 链接消息处理
 * Created by wxc on 2016/9/14.
 */
public abstract class LinkMessageDriver extends MessageDriverI {
    @Override
    public WechatResponse service(BaseMessage baseMessage) {
        WechatResponse response = super.service(baseMessage);
        if (!MsgType.link.name().equals(baseMessage.getMsgType()))
            throw new RuntimeException("不支持的消息类型");
        handle((LinkMessage) baseMessage);
        return response;
    }

    protected abstract void handle(LinkMessage message);
}
